﻿/*
=======================================================
    UsingWireropeAttr【在用绳附件】
=======================================================
*/

namespace Services
{
    public interface IUsingWireropeAttrRepository : IRepository<UsingWireropeAttr>
    {
    }


    public class UsingWireropeAttrRepository : BaseRepository<UsingWireropeAttr>, IUsingWireropeAttrRepository
    {
        public UsingWireropeAttrRepository(ISqlSugarClient dB, ICurrentUser currentUser, IQuery<UsingWireropeAttr> query)
            : base(dB, currentUser, query)
        {
        }

        public override (List<UsingWireropeAttr> items, int totalCount) GetPage(Expressionable<UsingWireropeAttr> where, int pageIndex = 1, int pageSize = 20, string orderBy = null)
        {
            var fs = _DB.Queryable<UsingWireropeAttr, UsingWirerope, Department>
                ((x, uw, d) => new JoinQueryInfos(
                     JoinType.Inner, x.UsingWireropeID == uw.UsingWireropeID,
                     JoinType.Inner, uw.DepartmentID == d.DepartmentID
                ))
                .Select((x, uw, d) => new UsingWireropeAttr
                {
                    UsingWireropeAttrID = x.UsingWireropeAttrID.SelectAll(),
                    UsingWirerope_Code = uw.Code,
                    UsingWirerope_Name = uw.Name,
                    UsingWirerope_DepartmentName = d.Name,
                });

            return _query.GetPage(where, pageIndex, pageSize, orderBy, fs);
        }
    }
}
